﻿
var _jsonData_wfz = [
    {
        "id": "3d66358b5c634e2dbf3d42b475f9a7d4",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 102,
        "patientKey": "999999999001",
        "patientName": "多大的1",
        "registerId": "1",
        "registerTime": "20180523095610",
        "timeType": 0,
        "triageTime": "20180523095620",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095620",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 102,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "b72a386bcf8146ada1e0df8939fe2d15",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 103,
        "patientKey": "999999999002",
        "patientName": "多大的2",
        "registerId": "2",
        "registerTime": "20180523095615",
        "timeType": 0,
        "triageTime": "20180523095621",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095621",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 103,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "1c15199a88e749ecab28e735c1825518",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 104,
        "patientKey": "999999999003",
        "patientName": "多大的3",
        "registerId": "3",
        "registerTime": "20180523095706",
        "timeType": 0,
        "triageTime": "20180523095720",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095720",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 104,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "56997af6970f4c329461ce26f8cd793c",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 105,
        "patientKey": "999999999004",
        "patientName": "多大的4",
        "registerId": "4",
        "registerTime": "20180523095711",
        "timeType": 0,
        "triageTime": "20180523095721",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095721",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 105,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "d4c18c9e3c9542d0931cdb804523ccec",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 106,
        "patientKey": "999999999005",
        "patientName": "多大的5",
        "registerId": "5",
        "registerTime": "20180523095714",
        "timeType": 0,
        "triageTime": "20180523095721",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095721",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 106,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "70e573d556b6413da4f90e3e0deb555d",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 107,
        "patientKey": "999999999006",
        "patientName": "多大的6",
        "registerId": "6",
        "registerTime": "20180523095718",
        "timeType": 0,
        "triageTime": "20180523095722",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095722",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 107,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "2ad4a189701141c7bb20dd39ccef648b",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 108,
        "patientKey": "999999999007",
        "patientName": "多大的7",
        "registerId": "7",
        "registerTime": "20180523095722",
        "timeType": 0,
        "triageTime": "20180523095740",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095740",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 108,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "7bf323f505ea421b8076429368ba0184",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 109,
        "patientKey": "999999999008",
        "patientName": "多大的8",
        "registerId": "8",
        "registerTime": "20180523095726",
        "timeType": 0,
        "triageTime": "20180523095741",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095741",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 109,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "c8e59934322d40cd8554ac12e9660ed6",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 110,
        "patientKey": "999999999009",
        "patientName": "多大的9",
        "registerId": "9",
        "registerTime": "20180523095730",
        "timeType": 0,
        "triageTime": "20180523095742",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095742",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 110,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999010",
        "patientName": "多大的10",
        "registerId": "10",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    },
    {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的11",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": "",
        "callingTime": null,
        "isReferral": 0
    }, {
        "id": "132cdf7fadeb4b5396c2f969cbc5608e11",
        "queueId": "68ba2e7819b040da871bbdc0a3c92c9d",
        "queuingKey": "1366f1f07da04346becdf6a898e97dc6",
        "queuingOrderNo": 111,
        "patientKey": "999999999011",
        "patientName": "多大的99x",
        "registerId": "11",
        "registerTime": "20180523095754",
        "timeType": 0,
        "triageTime": "20180523095800",
        "queuingDate": "20180523000000",
        "delayTime": 0,
        "delayEditTime": null,
        "editor": "automatic",
        "editTime": "20180523095800",
        "isDeleted": 0,
        "sex": 1,
        "signOrderNo": 111,
        "hospitalId": "4e66fabafd944e458dc259ce890c31f3",
        "remarks": null,
        "isNumRecall": 0,
        "isGreenChannel": 0,
        "treatStatus": 1,
        "treatmentStage": 1,
        "waitingStatus": 0,
        "treatmentEndStatus": -1,
        "doctorId": null,
        "doctorName": null,
        "callingTime": null,
        "isReferral": 0
    }
];


var dataGrid_hz,
    orderType_hz = '',
    orderField_hz = '',
    PAGESIZE_hz,
    pageCount_hz,
    rsCount_hz;

var wfz_datagridflg = false;

$(function () {
    //绿色通道
    $("#but_lstd").click(function () {
        var ids = getSelectedPatients();
        if (getStrArraySize(ids, ",") != 1) {
            layer.alert("请选择1位需要操作的患者！", { icon: 7 });
        } else {
            layer.alert("确定将当前未分诊患者设置为绿色通道吗？", {
                closeBtn: 0,
                btn: ['确定', '取消'],
                icon: 7,
                cancel: function () {

                },
                yes: function (index) {
                    // 调用延时方法
                    $.ajax({
                        url: _greenPipePatients,
                        type: "post",
                        data: {
                            id: ids,
                            greenChannelSource: 0
                        },
                        success: function (data) {
                            $("#but_fenz").attr('disabled', "disabled");
                            $("#but_fenz").css({"color":"#9d9d9d","font-weight":300});
                            $("#but_lstd").css({"color":"#9d9d9d","font-weight":300});
                            $("#but_lstd").attr('disabled', "disabled");
                            $("#but_gb").css({"color":"#9d9d9d","font-weight":300});
                            $("#but_gb").attr('disabled', "disabled");
                            showResult(index, data);
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            console.log(textStatus);
                            console.log(errorThrown);
                            layer.alert("操作失败!", { icon: 2 });
                        }
                    });
                }
            });
        }
    });
//广播
    $("#but_gb").click(function () {
        var _patKey = "";
        var _patName = "";
        $("#t_table_wfz_content :radio").each(function (key, value) {
            if ($(value).prop('checked')) {
                _patKey = $(this).parent().parent().parent().find("td:eq(2) >span").html();
                _patName = $(this).parent().parent().parent().find("td:eq(3) >span").html();
                // alert(_patKey + "__" + _patName);
            }
        });
        var _gbmsg = "请" + _patKey + "号" + _patName + "[p200]到分诊台";
        $.ajax({
            url: _broadcastUrl,
            type: 'get',
            data: {
                queueId: getLocalQueueId(),
                hospitalId: getHospitalId(),
                message: _gbmsg,
            },
            success: function (d) {
                var _status = JSON.parse(d).status;
                var _desc = JSON.parse(d).desc;
                if (_status == 0) {
                    layer.alert("广播成功", { icon: 1 });
                } else {
                    layer.alert(_desc, { icon: 2 });
                }
            }
        });
    });
    // 分诊页面弹框
    $("#but_fenz").click(function () {
        var id = getSignId ();
        var signId = getSelectedPatients();
        var signType = getSignType();
        var patientKey = getPatientKey();
        var queueKey = getQueueKey();
        var fenzFzType = "";//区分未分诊队列分诊和复诊按钮
        var fenzFzSignId = "fenzY";
        if( signType == 2){// 1初诊报到，2复诊报到
            fenzFzType = "fz";
        } else {
            fenzFzType = "fenz";
        }
        var winId = "triageWin";
        var buttonClicked = false;
        layer.open({
            id: winId,
            type: 2,
            title: false,
            shadeClose: false,
            closeBtn: 0,
            area: ['400px', '300px'],
            content: '../window/triage_win.html?systemId=' + getSystemId() + "&deptId=" + getDeptId()+ "&signId=" + signId+ "&queueKey=" + queueKey+ "&patientKey=" + patientKey+"&fenzFzType=" + fenzFzType+"&fenzFzSignId=" + fenzFzSignId,
            btn: ['确定', '取消'],
            cancel: function () {
            },
            yes: function (index, layero) {
                $("#but_fenz").attr('disabled', "disabled");
                $("#but_fenz").css({"color":"#9d9d9d","font-weight":300});
                $("#but_lstd").css({"color":"#9d9d9d","font-weight":300});
                $("#but_lstd").attr('disabled', "disabled");
                $("#but_gb").css({"color":"#9d9d9d","font-weight":300});
                $("#but_gb").attr('disabled', "disabled");
                if (!buttonClicked) {
                    buttonClicked = true;
//                  var result = true;
                    var frameId = document.getElementById(winId).getElementsByTagName('iframe')[0].id;
                    var result = $('#' + frameId)[0].contentWindow.checkBack();
                    console.log(result);
                    if (result != false) {
                        //parent.layer.close(index);
                        layer.alert("操作成功!", { icon: 1,time: 1000 });
                        requestWfzData();
                    }else{
                        buttonClicked = false;
                    }
                }
            }
        });
    });

    // 刷新按钮点击后，刷新页面
    $("#earlyFresh").click(function () {
        requestWfzData();
    });

    //扫描
    $("#cradScan").click(function () {
        my_cefsharp.Set_ReadCard_Mode("0");
        //执行弹出窗口 传入值
        ReadCardInfo_CallBack();
    });

    // 选择被动报到或者批量报到下拉按钮
    $("#btnSelectScan").click(function (){
        if($(".selelctScanImg").css("display") == "none"){
            $(".selelctScanImg").show();
            $(".selelctScanImg").css({ "display": "block" });
            if($("#bulkScan").css("display") == "none"){
                $("#bulkScanImg").show();
                $("#cradScanImg").hide();
            }else {
                $("#bulkScanImg").hide();
                $("#cradScanImg").show();
            }
        } else{
            $(".selelctScanImg").hide();
        }
    });
//点击批量读卡，切換批量和被动读卡图标
    $("#bulkScanImg").click(function () {
        $("#cradScan").hide();
        $("#bulkScan").show();
        $(".selelctScanImg").hide();
    });
//点击被动读卡，切換批量和被动读卡图标
    $("#cradScanImg").click(function () {
        $("#cradScan").show();
        $("#bulkScan").hide();
        $(".selelctScanImg").hide();
    });

    //批量报到
    $("#bulkScan").click(function () {
        my_cefsharp.Set_ReadCard_Mode("1");
        // c端批量刷卡
        var bulkPage = "bulkPage";
        layer.open({
            id: bulkPage,
            type: 2,
            title: "批量报到",
            shadeClose: false,
            closeBtn: 1,
            area: ['800px', '700px'],
            content: '../window/batch_register.html',
            cancel: function(){
                var frameId = document.getElementById(bulkPage).getElementsByTagName('iframe')[0].id;
                var result = $('#' + frameId)[0].contentWindow.patientCount();
                var msg ="当前无患者报到，是否确认关闭？";
                if( result > 0 ){
                    msg= "尚有患者未报到，是否确认关闭？";
                }
                layer.confirm(msg, {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    my_cefsharp.Set_ReadCard_Mode("0");
                    layer.closeAll();
                }, function(){
                });
                return false;//只有当点击confirm框的确定时，该层才会关闭
            }
        });
    });

    function ReadCardInfo_CallBack() {
        //⑬　获得身份证号码：
        // my_cefsharp.Get_People_ID_Cef(ReadCardInfo);
        //⑭　获得卡的UID号：
        my_cefsharp.Get_Card_UID_Cef(ReadCardInfo);

    }

    function ReadCardInfo(_patientKey) {
        layer.open({
            type: 2,
            title: "现场报到",
            shadeClose: true,
            closeBtn: 1,
            area: ['400px', '365px'],
            content: '../window/livecoverage_win.html?_patientKey=' + _patientKey,
            //content: './window/auto_checkin.html?idnumber=' + v,
        });

    }
    //手动挂号
    $("#img_sdlr").click(function () {
        layer.open({
            type: 2,
            title: "手动挂号",
            shadeClose: false,
            closeBtn: 1,
            area: ['400px', '360px'],
            content: '../window/manualEntering.html',
            success: function (layero, index) {
                // 禁用按钮防止重复提交
                $("#img_sdlr").attr({ disabled: "disabled" });
            },
            end: function () {
                // 禁用按钮防止重复提交
                $("#img_sdlr").removeAttr("disabled");
            }
        });
    });
    //现场报到
    $("#img_xcbd_wfz").click(function () {
        layer.open({
            type: 2,
            title: "现场报到",
            shadeClose: false,
            closeBtn: 1,
            area: ['400px', '365px'],
            content: '../window/livecoverage_win.html',
            success: function (layero, index) {
                // 禁用按钮防止重复提交
                $("#img_xcbd_wfz").attr({ disabled: "disabled" });
            },
            end: function () {
                // 禁用按钮防止重复提交
                $("#img_xcbd_wfz").removeAttr("disabled");
            }
        });
    });
    //语音播报
    $('#img_yybb').click(function () {
        layer.open({
            type: 2,
            title: '语音播报',
            shadeClose: true,
            area: ['80%', '60%'],
            content: '../window/voice.html'
        });
    });
    // 判断是否显示“绿色通道”按钮
    refreshWfzGreenChannelButton();
});


// 显示操作结果
function showResult(index, data) {
    parent.layer.close(index);
    if (data != null && data != "") {
        var result = JSON.parse(data);
        if (result.status == 0) {
            layer.alert("操作成功!", { icon: 1 });
            requestWfzData();
        } else {
            layer.alert(result.desc, { icon: 2 });
        }
    } else {
        layer.alert("操作失败", { icon: 2 });
    }
}

/**
 * 获取选中的患者信息
 * @returns {string}
 */
function getPatientsInfo() {
    var patients = new Array();
    //console.log("选中的tab:" + selectedTab);
    $("#t_table_wfz_content :radio").each(function (key, value) {
        if ($(value).prop('checked')) {
            var id = $(this).attr("id");
            var queueKey = $(this).attr("data-queueKey");
            var content = id + ":" + queueKey;
            patients.push(content);
        }
    });

    return patients.join(",");
}
/**
 * 获取选中的患者id
 * @returns {string}
 */
function getSelectedPatients() {
    var ids = new Array();

    var patients = getPatientsInfo();
    var pts = patients.split(",");
    var i = 0, len = pts.length;
    for (; i < len; i++) {
        var item = pts[i];
        var array = item.split(':');
        ids.push(array[0]);
    }

    return ids.join(',');
}
//判断患者初诊signid
function getSignId() {
    var id = "";
    $("#t_table_wfz_content :radio").each(function (key, value) {
        if ($(value).prop('checked')) {
            id = $(this).attr("id");
        }
    });
    return id;
}
//判断患者初诊/复诊
function getSignType() {
    var signType = "";
    $("#t_table_wfz_content :radio").each(function (key, value) {
        if ($(value).prop('checked')) {
            signType = $(this).attr("data-signType");
        }
    });
    return signType;
}
//判断患者初诊/复诊
function getPatientKey() {
    var patientKey = "";
    $("#t_table_wfz_content :radio").each(function (key, value) {
        if ($(value).prop('checked')) {
            patientKey = $(this).attr("data-patientKey");
        }
    });
    return patientKey;
}
//判断患者初诊/复诊
function getQueueKey() {
    var queueKey = "";
    $("#t_table_wfz_content :radio").each(function (key, value) {
        if ($(value).prop('checked')) {
            queueKey = $(this).attr("data-queueKey");
        }
    });
    return queueKey;
}
// 请求未分诊列表数据
function requestWfzData() {
    localStorage.setItem("_ISNOSPLIT_PAGE_", "Y");
    var systemId = getSystemId();
    $.ajax({
        url: _undiagnosedUrl,
        type: "get",
        data: {
            systemId: systemId
        },
        success: function (data) {
            var result = JSON.parse(data);
            if (result.status == 0) {
                loadWfzDataGrid(result.data);
            } else {
                loadDataFailed("没有未分诊的患者", 11);
            }
        },
        error: function (jqXHR, textStatus, errorThrown) {
            console.log(textStatus);
            console.log(errorThrown);
            loadDataFailed("获取未分诊列表数据失败", 11);
        }
    });

    //var jsonitems = _jsonData_wfz;
    // loadWfzDataGrid(jsonitems);
}


function wfz_checkall(_this) {
    var chkbox = $(_this);
    if (chkbox.prop("checked")) {
        $("#t_table_wfz_content :radio").each(function () {
            $(this).prop("checked", "checked");

            $(this).parent().parent().find("span").css({
                "border-top": "1px solid #3598db",
                "border-bottom": "1px solid #3598db",
                "border-left": "1px solid #3598db",
                "background-color": "#F2F3F3"
            });

            $(this).parent().parent().nextAll().find("span").each(function () {
                $(this).css({
                    "border-top": "1px solid #3598db",
                    "border-bottom": "1px solid #3598db",
                    "background-color": "#F2F3F3"
                });
            })

            $(this).parent().parent().nextAll().last().find("span").css({
                "border-right": "1px solid #3598db",
                "background-color": "#F2F3F3"
            });

        })
    } else {
        $("#t_table_wfz_content :radio").each(function () {
            $(this).prop("checked", false);

            $(this).parent().parent().find("span").css({
                "border-top": "",
                "border-bottom": "",
                "border-left": "",
                "background-color": "#FFFFFF"
            });

            $(this).parent().parent().nextAll().find("span").each(function () {
                $(this).css({
                    "border-top": "",
                    "border-bottom": "",
                    "background-color": "#FFFFFF"
                });
            })

            $(this).parent().parent().nextAll().last().find("span").css({
                "border-right": "",
                "background-color": "#FFFFFF"
            });
        })
    }
}

//构建复诊表格结构
function loadWfzDataGrid(d /* String */) {
    var totalNum = 0;
    var _html = "";

    var _queryKey = localStorage.getItem("_P_KEY_") == null ? "" : localStorage.getItem("_P_KEY_");
    var _initSelected = false;

    //测试放开

    //alert("loadWfzDataGrid--->" + _queryKey);
    if (d !== null) {
        var count = 0;
        totalNum = d.length;
        for (var i = 0; i < d.length; i++) {
            var _fznumber = getNotBlankData(d[i].registerId);
            var _hzname = getNotBlankData(d[i].patientName);
            var _doctorname = getNotBlankData(d[i].docName);
            var _status = "未分诊";
            var _ys = "";
            var _wb = getTimeName(d[i].timeType);
            var _ghtm = getNotBlankData(d[i].registerTime);
            var _jhtm = "";
            var _remark = getNotBlankData(d[i].remarks);
            var _queueKey = getNotBlankData(d[i].registerObjKey);
            var _patientKey = getNotBlankData(d[i].patientKey);

            count++;

            var _inputRadio = "";
            if (_queryKey == d[i].signId) {

                localStorage.setItem("_P_KEY_", "");
                _initSelected = true;
                _inputRadio = "<input type='radio' checked='checked' name='sel_patient' id='"
                    + d[i].signId +"' data-signType = '"+d[i].signType + "' data-queueKey = '"
                    + _queueKey +"' data-patientKey = '"+d[i].patientKey + "' name='yjz_"
                    + _fznumber + "' onclick='select_wfz_row(this)'/>";

            } else {
                _inputRadio = "<input type='radio' name='sel_patient' id='"
                    + d[i].signId +"' data-signType = '"+d[i].signType + "' data-queueKey = '"
                    + _queueKey +"' data-patientKey = '"+d[i].patientKey+ "' name='yjz_"
                    + _fznumber + "' onclick='select_wfz_row(this)'/>";
            }


            _html += "<tr>";
            _html += "<td><span>" + _inputRadio + "</span></td>";
            _html += "<td><span>" + count + "</span></td>";
            _html += "<td><span>" + _fznumber + "</span></td>";
            _html += "<td><span>" + _hzname + "</span></td>";
            _html += "<td><span>" + _doctorname + "</span></td>";
            _html += "<td><span>" + _status + "</span></td>";
            _html += "<td><span>" + _ys + "</span></td>";
            _html += "<td><span>" + _wb + "</span></td>";
            _html += "<td><span>" + _ghtm + "</span></td>";
            _html += "<td><span>" + _jhtm + "</span></td>";
            _html += "<td style='text-overflow: ellipsis; white-space: nowrap; overflow: hidden;' title='" + _remark + "'><a data-id='" + d[i].signId + "' data-remark='" + _remark + "' onclick='set_wfz_remark(this);'><span>" + _remark + "</span></a></td>";

            _html += "</tr>";
        }
    }

    $("#t_table_wfz_content").html(_html);
    //$("#t_table_wfz_content").html(d.length);

    //表头排序
    $('#table_wfz').tablesort().data('tablesort');
    $('thead th.number').data('sortBy', function (th, td, sorter) {
        return parseInt(td.text(), 10);
    });

    // 写入脚标
    console.log(totalNum);
    $('#wfz_patientNum').html("总共" + totalNum + "位患者!");
    //是否有搜索，需要初始化选中效果
    if (_initSelected) {
        var _t = $("#" + _queryKey);
        select_wfz_row(_t);
    }
}

//选择一行
function select_wfz_row(t) {
    console.log($(t).prop("checked"));
    var _ischeked = $(t).prop("checked");
    //设置本行变色
    if (_ischeked) {
        $(t).parent().parent().find("span").css({
            "border-top": "1px solid #3598db",
            "border-bottom": "1px solid #3598db",
            "border-left": "1px solid #3598db",
            "background-color": "#F2F3F3"
        });

        $(t).parent().parent().nextAll().each(function () {
            $(this).find("span").css({
                "border-top": "1px solid #3598db",
                "border-bottom": "1px solid #3598db",
                "background-color": "#F2F3F3"
            });
        });

        $(t).parent().parent().parent().prevAll().each(function () {
            $(this).find("span").css({
                "border-top": "",
                "border-bottom": "",
                "border-left": "",
                "background-color": "#FFFFFF"
            });
        });

        $(t).parent().parent().parent().nextAll().each(function () {
            $(this).find("span").css({
                "border-top": "",
                "border-bottom": "",
                "border-left": "",
                "background-color": "#FFFFFF"
            });
        });

        //$(t).parent().parent().nextAll().last().find("span").css({
        //    "border-right": "1px solid #3598db",
        //    "background-color": "#F2F3F3"
        //});
        $("#but_fenz").removeAttr("disabled");
        $("#but_fenz").css({"color":"#000000","font-weight":700});
        $("#but_lstd").removeAttr("disabled");
        $("#but_lstd").css({"color":"#000000","font-weight":700});
        $("#but_gb").removeAttr("disabled");
        $("#but_gb").css({"color":"#000000","font-weight":700});
    }
    /*//取消本行变色
     else {
     $(t).parent().parent().find("span").css({
     "border-top": "",
     "border-bottom": "",
     "border-left": "",
     "background-color": "#FFFFFF"
     });

     $(t).parent().parent().nextAll().each(function () {
     $(this).find("span").css({
     "border-top": "",
     "border-bottom": "",
     "background-color": "#FFFFFF"
     });
     });

     $(t).parent().parent().nextAll().last().find("span").css({
     "border-right": "",
     "background-color": "#FFFFFF"
     });
     }*/
}

/**
 * 刷新页面“绿色通道”按钮是否显示
 */
function refreshWfzGreenChannelButton() {
    if (GetQueryString("greenChannel") == "1") {
        $("#but_lstd").show();
    } else {
        $("#but_lstd").hide();
    }
}


/**
 * 对未分诊患者做备注操作
 * @param _this
 */
function set_wfz_remark(_this) {
    var id = $(_this).attr("data-id");
    var remark = $(_this).attr("data-remark");

    var win_name = "noRemark";
    layer.open({
        id: win_name,
        type: 2,
        title: false,
        shadeClose: false,
        closeBtn: 0,
        area: ['400px', '200px'],
        content: '../window/no_triage_remark.html?id=' + id + "&remark=" + remark,
        btn: ['确定', '取消'],
        yes: function (index, layero) {
            var frameId = document.getElementById(win_name).getElementsByTagName('iframe')[0].id;
            var result = $('#' + frameId)[0].contentWindow.setRemark();
            console.log(result);
            if (result != false) {
                layer.close(index);
                requestWfzData();
            }
        },
        cancel: function () {

        }
    });
}

//c端调b端方法（index.js)，传患者就诊卡号，未分诊页面从index页面获取后将值传给弹窗
function passCardInfo(cardInfo){
   var passCard =cardInfo;
   var frameId = document.getElementById("bulkPage").getElementsByTagName('iframe')[0].id;
   $('#' + frameId)[0].contentWindow.passCardToBatch(passCard);
}


